import java.io.*;
import java.util.Arrays;

public class IOdemo4 {
    public static void main(String[] args) {
        File file = new File("D:/demo.txt");

        System.out.println(file.exists());

        File file1=new File("D:/demo1.txt");
        try {
            if(file1.createNewFile()){
                System.out.println("文件创建成功"+file1.getName());
            }
            else {
                System.out.println("文件不存在或已经创建成功");
            }

            FileWriter fileWriter=new FileWriter(file1);

            BufferedWriter bufferedInputStream=new BufferedWriter(fileWriter);

            FileWriter writer=new FileWriter(file);

            writer.write("A");
            writer.flush();
            bufferedInputStream.write("这是写入的第一行\n");
            bufferedInputStream.write("这是写入的第二行");
            bufferedInputStream.close();

            System.out.println("内容写入成功");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


    }
}
